﻿#include <stdio.h>
#include "SeqList.h"

// 测试函数
void test1() 
{
	// 定义顺序表
	SeqList list;
	// 初始化顺序表
	SeqListInit(&list, 5);

	//插入5个元素
	SeqListPushBack(&list, 1);
	SeqListPushBack(&list, 2);
	SeqListPushBack(&list, 3);
	SeqListPushBack(&list, 4);
	SeqListPushBack(&list, 5);
	// 插入第6个元素，触发扩容
	SeqListPushBack(&list, 6);
	// 遍历顺序表
	SeqListTraverse(&list);

	// 查找元素6的下标
	int index = SeqListFind(&list, 3);
	printf("6 is located at %d\n", index);

	// 删除元素6
	SeqListErase(&list, index);
	index = SeqListFind(&list, 3);
	printf("6 is located at %d\n", index);

	// 头插5个元素
	SeqListPushFront(&list, 1);
	SeqListPushFront(&list, 2);
	SeqListPushFront(&list, 3);
	SeqListPushFront(&list, 4);
	SeqListPushFront(&list, 5);

	// 遍历顺序表
	SeqListTraverse(&list);

	// 头尾各删除两个
	SeqListPopBack(&list);
	SeqListPopBack(&list);
	SeqListPopFront(&list);
	SeqListPopFront(&list);

	// 遍历顺序表
	SeqListTraverse(&list);
}



int main() 
{
	test1();
	return 0;
}